from fastapi import APIRouter

from app.database.postgre import SessionDep
from app.models.common import CardTypeIdJson, CardTypeIdParams, AppIdParams
from app.models.card_types import AppCardTypesListParams, CreateCardTypeJson, UpdateCardTypeJson
from app.services import accounts, card_types

router = APIRouter(
    prefix='/api/v1/card_types',
    tags=['backend', 'card_types']
)


@router.get('/list')
async def card_types_list(account: accounts.LoggedInAccount,
                          query_params: AppCardTypesListParams,
                          session: SessionDep, ):
    response = await card_types.get_card_types_list(account, query_params, session)
    return response


@router.post('/create')
async def create_card_type(account: accounts.LoggedInAccount,
                           json_data: CreateCardTypeJson,
                           session: SessionDep):
    response = await card_types.create_new_card_type(account, json_data, session)
    return response


@router.post('/delete')
async def delete_card_type(account: accounts.LoggedInAccount,
                           json_data: CardTypeIdJson,
                           session: SessionDep):
    response = await card_types.delete_card_type(account, json_data, session)
    return response


@router.get('/info')
async def card_type_info(account: accounts.LoggedInAccount,
                         query_params: CardTypeIdParams,
                         session: SessionDep):
    response = await card_types.get_card_type_info(account, query_params, session)
    return response


@router.post('/update')
async def update_card_type(account: accounts.LoggedInAccount,
                           json_data: UpdateCardTypeJson,
                           session: SessionDep):
    response = await card_types.update_card_type(account, json_data, session)
    return response


@router.get('/simple')
async def simple_types(account: accounts.LoggedInAccount, query_params: AppIdParams, session: SessionDep):
    response = await card_types.get_simple_card_types(account, query_params, session)
    return response
